package run

import (
	"gitee.com/pkg/root"
	"gitee.com/pkg/utils/flag"
	"gitee.com/pkg/vvlog"
	"github.com/spf13/cobra"
	"os"
	"os/exec"
)

var (
	logger = vvlog.NewLogger("run.go")
	runCmd = &cobra.Command{
		Use:   "run",
		Short: "run\" demo",
		RunE: func(c *cobra.Command, args []string) error {
			flag.PrintFlags(c.Flags())
			logger.Info("to do ")
			return runc()
		},
	}
)

func init() {
	//servCmd.PersistentFlags().StringVar(&sslKey, "key", "", "serv's ssl key")
	root.AddCmd(runCmd)
}

func runc() error {
	cmd := exec.Command("/bin/sh", "-c",
		"env",
	)
	//cmd.Stdout=&writer.StdOutWrapper{W: os.Stdout,Eds:eds}
	//cmd.Stderr=&writer.StdOutWrapper{W: os.Stderr,Eds:eds}
	cmd.Stdout = os.Stdout
	cmd.Stdin = os.Stdin
	cmd.Stderr = os.Stderr
	cmd.Start()
	return cmd.Wait()
}
